/-editor
/-files
/-imports ...
/-imports/acorn ...
acorn.js
acorn_loose.js
walk.js
/-imports/codemirror
active-line.js
brace-fold.js
closebrackets.js
closetag.js
codemirror.css
codemirror.js
comment-fold.js
comment.js
continuecomment.js
css.js
dialog.css
dialog.js
foldcode.js
foldgutter.css
foldgutter.js
html-hint.js
htmlembedded.js
htmlmixed.js
javascript-hint.js
javascript.js
match-highlighter.js
matchbrackets.js
search.js
searchcursor.js
show-hint.css
show-hint.js
tern.css
tern.js
trailingspace.js
xml-fold.js
xml-hint.js
xml.js
/-imports/knockout
/-imports/tern
/-imports/typescript
lib.d.ts
typescriptServices.js
/-imports/zip.js
/-layout
/-typings
TypeScriptService.ts
ko.ts
persistence.ts
shell.ts
teapo.html
teapo.js
teapo.ts
785
      /[enwfd]/.test(ch) && /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(input.slice(pos - 10, pos));
1
// Acorn: Loose parser
2
//
3
// This module provides an alternative parser (`parse_dammit`) that
4
// exposes that same interface as `parse`, but will try to parse
5
// anything as JavaScript, repairing syntax error the best it can.
6
// There are circumstances in which it will raise an error and give
7
// up, but they are very rare. The resulting AST will be a mostly
8
// valid JavaScript AST (as per the [Mozilla parser API][api], except
9
// that:
10
//
11
// - Return outside functions is allowed
12
//
13
// - Label consistency (no conflicts, break only to existing labels)
14
//   is not enforced.
15
//
16
// - Bogus Identifier nodes with a name of `"*"` are inserted whenever
17
//   the parser got too confused to return anything meaningful.
18
//
19
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
20
//
21
// The expected use for this is to *first* try `acorn.parse`, and only
22
// if that fails switch to `parse_dammit`. The loose parser might
23
// parse badly indented code incorrectly, so **don't** use it as
24
// your default parser.
25
//
26
// Quite a lot of acorn.js is duplicated here. The alternative was to
27
// add a *lot* of extra cruft to that file, making it less readable
28
// and slower. Copying and editing the code allowed me to make
29
// invasive changes and simplifications without creating a complicated
30
// tangle.
31
32
(function(root, mod) {
33
  if (typeof exports == "object" && typeof module == "object") return mod(exports, require("./acorn")); // CommonJS
34
  if (typeof define == "function" && define.amd) return define(["exports", "./acorn"], mod); // AMD
35
  mod(root.acorn || (root.acorn = {}), root.acorn); // Plain browser env
36
})(this, function(exports, acorn) {
37
  "use strict";
38
39
  var tt = acorn.tokTypes;
40
41
  var options, input, fetchToken, context;
42
43
  exports.parse_dammit = function(inpt, opts) {
44
    if (!opts) opts = {};
45
    input = String(inpt);
46
    options = opts;
47
    if (!opts.tabSize) opts.tabSize = 4;
48
    fetchToken = acorn.tokenize(inpt, opts);
49
    sourceFile = options.sourceFile || null;
50
    context = [];
51
    nextLineStart = 0;
52
    ahead.length = 0;
53
    next();
54
    return parseTopLevel();
55
  };
56
57
  var lastEnd, token = {start: 0, end: 0}, ahead = [];
ready.